//
//  ContactCell.m
//  timelyRain
//
//  Created by Jiafei Wei on 16/9/18.
//  Copyright © 2016年 Jiafei Wei. All rights reserved.
//

#import "ContactCell.h"
#import "MBTPre.h"

@interface ContactCell(){
     ContactCell *cell;
}
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *group;



@end
@implementation ContactCell

- (void)awakeFromNib {
    [super awakeFromNib];
    _headerLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(headerLongPress:)];
    [self addGestureRecognizer:_headerLongPress];
    _image.layer.masksToBounds=YES;
    _image.layer.cornerRadius=_image.frame.size.height/2;
}

//创建自定义可重用的cell对象
+(instancetype)setContactCellWithTableView:(UITableView *)tableView
{
    static NSString *reuseId = @"ContactCell";
     ContactCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseId];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ContactCell" owner:nil options:nil] lastObject];
    }
    return cell;
}

- (void)headerLongPress:(UILongPressGestureRecognizer *)longPress
{
    if (longPress.state == UIGestureRecognizerStateBegan) {
        if(_delegate && _indexPath && [_delegate respondsToSelector:@selector(cellImageViewLongPressAtIndexPath:)])
        {
            [_delegate cellImageViewLongPressAtIndexPath:self.indexPath];
        }
    }
}
-(void)setData:(TContact *)data{
    _data =data;
    _name.text =_data.name;
    _group.text =_data.group;
//    NSLog(@"_data.group=====是图片啊%@",_data.group);
//    if (![_data.group isEqualToString:@""]) {
//        [_image sd_setImageWithURL:[NSURL URLWithString:_data.group]];
//    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}
@end
